#include <cstdio>
#include <cstring>

using namespace std;

const int maxn = 21;

int logt[1 << maxn];

void initLog(int n) {
  for (int i = 0; i <= n; i++) {
    logt[1 << i] = i;
  }
}

int next(int n, int a, int x) {
  a = x ? a : ~a;
  return a&(-a) ? logt[a&(-a)]+1 : n+1;
}

void print(int n, int a) {
  for (int i = n; i > 0; i--) {
    printf("%d", (a >> (i - 1)) & 1);
  }
  printf("\n");
}

int main() {
#ifdef DEBUG
  freopen("in", "r", stdin);
  freopen("out", "w", stdout);
#endif

  static int f[2][maxn + 1][1 << maxn], que[2][(1 << maxn)+10][2], qn[2],
      book[2][maxn+1][1 << maxn];
  int n, k;
  scanf("%d %d", &n, &k);
  initLog(n);
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j < (1 << i); j++) {
      int t;
      scanf("%1d", &t);
      if (t) {
        f[0][i][j] = 1;
        que[0][++qn[0]][0] = i, que[0][qn[0]][1] = j;
        book[0][i][j] = 0;
      }
    }
  }

  int ans = 0, an = 0;
  for (int i = 0, p = 0; i < n; i++, p = !p) {
    qn[!p] = 0;
    memset(f[!p][0], 0, sizeof f[!p][0]);

    for (int j = 1; j <= qn[p]; j++) {
      int x = que[p][j][0], y = que[p][j][1], s = y % (1 << i), t = y >> i, ss,
          tt, xx, yy;
      if (x) {
        for (int k = 0; k < 2; k++) {
          ss = s + (k << i), xx = x - next(x, t, k), tt = t >> (x - xx),
          yy = ss + (tt << (i + 1));
          if (xx>0) {
            if (book[!p][xx][yy] != i + 1) {
              book[!p][xx][yy] = i + 1;
              f[!p][xx][yy] = f[p][x][y];
              que[!p][++qn[!p]][0] = xx;
              que[!p][qn[!p]][1] = yy;
            } else {
              f[!p][xx][yy] += f[p][x][y];
            }
          }
          if (xx >= 0) {
            f[!p][0][ss] += f[p][x][y];
          }
        }
      }
    }

    for (int j = 0; j < (1 << (i + 1)); j++) {
      if (f[!p][0][j] >= k && (i + 1 > an || (i + 1 == an && ans > j))) {
        an = i + 1, ans = j;
      }
    }
  }

  print(an, ans);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
